#ifndef BONE_H_
#define BONE_H_
#include "BoneList.h"
#include "TextureBox.h"

//a bone has an implicit starting point (the location of the joint it connects to)
//a bone has an angle and length ("orientation")
//a bone has a list of outgoing bones
//a bone has a texture and textureVertices
//the bone's texture box has a size (height and width)
//the bone's texture box has a location (located at a position along the bone)
#define MAX_DISPLAY_MODES 2
class Bone
{	
	Bone * parent;
	
	BoneList * outgoingBones;
	TextureBox * textureBox;
	float tbShift;
	float angle;
	float length;
	
	Vertex endPoint;
		
	bool holdingEndpoint;
	bool holdingTextureBox;
	bool holdingTbCp;
	int displayMode;
	bool controlLock;
	
	public:
	Bone(Bone * parent, float angle, float length, float tbShift, TextureBox * textureBox);
	Bone(Bone * parent, float angle, float length, TextureBox * textureBox);
	Bone(Bone * parent, Vertex endPoint, TextureBox * textureBox);
	
	~Bone();
	
	void CalculateAngleLength();
	void CalculatePosition();
	void AddBone(Bone * bone);
	void RemoveBone(Bone * bone);
	
	void MoveEndPoint(Vertex endPoint);
	Vertex GetEndPoint();
	Bone * GetParent();
	char * GetTag();
	char * GetPose();
	void Draw();
	Bone * Click(Vector2D headPosition, Mouse * mouse);
	bool Drag(Vector2D headPosition, Mouse * mouse);
	void UnClick();
	float GetAngle();
	float GetFullAngle();
	Vector2D ToTextureBoxSpace(Vector2D headPosition, Vector2D mouseSpot);
	void SetTile(Tile * tile);
	void RotateClockwise();
	void RotateAntiClockwise();
	void Remove(Bone * bone);
	void RemoveMe();
	void ToggleDisplay();
	void ToggleLock();
	
};
#endif /*BONE_H_*/
